package nn.db.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import nn.db.entity.Permission;
import nn.db.mapper.PermissionMapper;
import nn.db.service.PermissionService;
import org.springframework.stereotype.Service;

import java.util.Arrays;
import java.util.List;

/**
 * <p>
 * 权限表 服务实现类
 * </p>
 *
 * @author mfx
 * @since 2020-10-27
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {

    @Override
    public String[] getPermissionStrs(Integer[] id) {
        List<Permission> permissions = list(new QueryWrapper<Permission>().in("role_id", Arrays.asList(id)));
        String[] permissionStrs=new String[permissions.size()];
        for(int i=0;i<permissions.size();i++){
            permissionStrs[i]=permissions.get(i).getPermission();
        }

        return permissionStrs;
    }
}
